package com.woniu.user.controller;

import com.woniu.common.pojo.Ping;
import com.woniu.common.vo.AjaxResult;
import com.woniu.user.service.PingService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/ping")
@CrossOrigin
public class PingController {
    @Resource
    private PingService pingService;

    //    查询所有评论
    @RequestMapping("/selectAllPing")
    public AjaxResult selectAllPing() {
        List<Ping> pingList = pingService.selectAllPing();
        for (Ping ping : pingList) {
            System.out.println("评论信息：" + ping);
        }
        return AjaxResult.success("评论准备完毕:", pingList);
    }

//    添加评论
    @RequestMapping("/addPing")
    public AjaxResult addPing(@RequestBody Ping ping) {
        System.out.println("评论信息：" + ping);
        pingService.addPing(ping);
        return AjaxResult.success("评论添加成功");
    }
}
